package ncku.account.gui;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuItem;

import ncku.account.event.Launcher;



public class toolBarTransaction {
	JMenu transactionMenu; 
	JMenuItem new_transactionItem;
	JMenuItem show_transactionItem;
	
	public toolBarTransaction(){
		
		transactionMenu = new JMenu ("交易");
		
		new_transactionItem = new JMenuItem ("新增交易");
		new_transactionItem.addActionListener(new New_Transaction());
		
		show_transactionItem = new JMenuItem ("列出交易清單");
		show_transactionItem.addActionListener(new Show_Transaction());
		
		transactionMenu.add (new_transactionItem);
		transactionMenu.add (show_transactionItem);
    
	}

	//此class 為listener，自行寫入動作
	class New_Transaction implements ActionListener{
		//建構式，不需要可刪除
		public New_Transaction(){
			
		}
		
		@Override
		public void actionPerformed(ActionEvent e) {
			 
			//這段code是去掉現有的panel，並加入你自已的panel，add 裡面的new 請放上自已的class
			Launcher.frame.getContentPane().remove(1);
			Launcher.frame.getContentPane().add (BorderLayout.CENTER,new newTransaction());
			Launcher.frame.getContentPane().doLayout();
		}
	}
	//此class 為listener，自行寫入動作
	class Show_Transaction implements ActionListener{
		//建構式，不需要可刪除
		public Show_Transaction(){
		
		}
	
		@Override
		public void actionPerformed(ActionEvent e) {
		
			 
			//這段code是去掉現有的panel，並加入你自已的panel，add 裡面的new 請放上自已的class
			Launcher.frame.getContentPane().remove(1);
			Launcher.frame.getContentPane().add (BorderLayout.CENTER,new showTransaction());
			Launcher.frame.getContentPane().doLayout();
		}
	}
	
	
	
}
